-
Notifications
You must be signed in to change notification settings - Fork 260
Fix the wrong computation of dynamic strides for lowering AllocOp to LLVM #338
base: master
Are you sure you want to change the base?
Conversation
MSVC has trouble resolving the static 'printOptionValue' from the method on llvm::cl::opt/list. This change renames the static method to avoid this conflict. PiperOrigin-RevId: 286978351
48dcae0
to
3722f03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! There's one extra simplification that can be made to make the code cleaner.
@@ -1054,14 +1054,15 @@ struct AllocOpLowering : public LLVMLegalizationPattern<AllocOp> { | |||
// Iterate strides in reverse order, compute runningStride and strideValues. | |||
auto nStrides = strides.size(); | |||
SmallVector<Value, 4> strideValues(nStrides, nullptr); | |||
for (auto indexedStride : llvm::enumerate(llvm::reverse(strides))) { | |||
for (auto indexedStride : llvm::enumerate(strides)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, enumerate
is useless here, the body of the loop never accesses indexedStride.value()
. Could you just rewrite the loop to iterate on index
to remove the confusion that led to the bug in the first place?
Thanks, @ftynse! I removed |
…cOp to LLVM Leftover change from before the MLIR merge, reviewed at accepted at tensorflow/mlir#338.
Landed as llvm/llvm-project@e5957ac. Since MLIR moved to LLVM, please submit your following contributions through https://reviews.llvm.org. Thank you! @joker-eph could you please close? |
…cOp to LLVM Leftover change from before the MLIR merge, reviewed at accepted at tensorflow/mlir#338.
…cOp to LLVM Leftover change from before the MLIR merge, reviewed at accepted at tensorflow/mlir#338.
The computation of dynamic strides in lowering AllocOp was wrong.
Given a MemRefType with
sizes = [5, 10]
, it computedstrides = [5, 1]
, while the correct answer should bestrides = [10, 1]
.